import { uniFileUpload, request } from '@/utils/request';

/** 签名 */
export const uploadFile = (file) => {
  return uniFileUpload<{ data: any }>({
    url: `/oss/sysOss/upload`,
    filePath: file,
    name: 'file',
    header: {
      VERSION: 'server',
    },
  });
};

export const getRdDemandPage = (query?: Object) => {
  return request<{ data: any }>({
    url: `/pm/rdDemand/getRdDemandPage`,
    method: 'GET',
    query: query,
  });
};
export const getRdDemandPageGongying = (query?: Object) => {
  return request<{ data: any }>({
    url: `/pm/rdDemand/vendorDemandPage`,
    method: 'GET',
    query: query,
  });
};

export const getObj = (data?: Object) => {
  return request<{ data: any }>({
    url: `/pm/rdDemand/getByIdSql`,
    method: 'POST',
    data: data,
  });
};
export const getGongyingObj = (data?: Object) => {
  return request<{ data: any }>({
    url: `/pm/rdDemand/vendorDemandDetail`,
    method: 'POST',
    data: data,
  });
};

export const getPersonByPersonCode = (query?: Object) => {
  return request<{ data: any }>({
    url: '/admin/hrPerson/getPersonByPersonCode',
    method: 'GET',
    query: query,
  });
};
export const getPersonByPersonCodeAndTantent = (query?: Object) => {
  return request<{ data: any }>({
    url: '/admin/hrPerson/getPersonByMap',
    method: 'GET',
    query: query,
  });
};

export const updateByIdEvery = (data?: Object) => {
  return request<{ data: any }>({
    url: '/pm/rdDemand/updateByIdEvery',
    method: 'PUT',
    data: data,
  });
};

export const uploadSignature = (data?: Object) => {
  return request<{ data: any }>({
    url: '/admin/hrPerson/uploadSignature',
    method: 'POST',
    data: data,
  });
};

export const completeTask = (obj?: Object, id?: string) => {
  return request<{ data: any }>({
    url: '/pm/rdDemand/complete?id=' + id,
    method: 'POST',
    data: obj,
  });
};

export const selectTaskByProcessInstanceId = (query?: Object) => {
  return request<{ data: any }>({
    url: '/engine/task/selectTaskByProcessInstanceId',
    method: 'GET',
    query: query,
  });
};

export function getBaseDemandType(query?: object) {
  return request({
    url: '/pm/baseDemandType/page',
    method: 'GET',
    query: query,
  });
}

export function getPmDict(query?: Object) {
  return request({
    url: '/pm/dict/item/page',
    method: 'GET',
    query: query,
  });
}

export function getSequenceNo(query?: Object) {
  return request({
    url: '/pm/rdDemand/getSequenceNo',
    method: 'GET',
    query: query,
  });
}

export function getbaseCustomer(query?: Object) {
  return request({
    url: '/pm/baseCustomer/page',
    method: 'GET',
    query: query,
  });
}
export function getbaseGongying(query?: Object) {
  return request({
    url: '/pm/baseVendor/page',
    method: 'GET',
    query: query,
  });
}

export function addObj(obj?: Object) {
  return request({
    url: '/pm/rdDemand',
    method: 'POST',
    data: obj,
  });
}

export function putObj(obj?: Object) {
  return request({
    url: '/pm/rdDemand',
    method: 'PUT',
    data: obj,
  });
}

export function submitProcess(id?: string) {
  return request({
    url: '/pm/rdDemand/submitProcess/' + id,
    method: 'GET',
  });
}

export function revokeProcess(query?: Object) {
  return request({
    url: '/pm/rdDemand/revoke',
    method: 'GET',
    query: query,
  });
}

export function delObj(ids?: object) {
  return request({
    url: '/pm/rdDemand',
    method: 'DELETE',
    data: ids,
  });
}

export function listLastNodePerson(query?: object) {
  return request({
    url: '/engine/history/listLastNodePerson',
    method: 'GET',
    query: query,
  });
}

export function reviveProcess(id?: string) {
  return request({
    url: '/pm/rdDemand/reviveProcess/' + id,
    method: 'GET',
  });
}

export function searchbaseInv(query?: Object) {
  return request({
    url: '/pm/baseInv/page',
    method: 'GET',
    query: query,
  });
}

export function selectrdDocumentsPostUser(query?: Object) {
  return request({
    url: '/pm/rdDocumentsPostUser/selectRdDocumentsPostUser',
    method: 'GET',
    query: query,
  });
}

export function updaterdProjectUser(obj?: Object) {
  return request({
    url: '/pm/rdProjectUser',
    method: 'PUT',
    data: obj,
  });
}

export function selectrdDocumentsPostDict(query?: Object) {
  return request({
    url: '/pm/rdDocumentsPostDict/selectRdDocumentsPostDict',
    method: 'GET',
    query: query,
  });
}

export function updateSignHandle(obj?: Object) {
  return request({
    url: '/pm/rdProjectUser/updateSign',
    method: 'PUT',
    data: obj,
  });
}

export function getInventoryCategory(query?: Object) {
  return request({
    url: '/u8/inventory/inventoryCategory',
    method: 'GET',
    query: query,
  });
}

export function getInventoryInfo(query?: Object) {
  return request({
    url: '/u8/inventory/inventoryInfo',
    method: 'GET',
    query: query,
  });
}

export function selectCheckTarget(query?: Object) {
  return request({
    url: '/u8/checkTarget/selectCheckTarget',
    method: 'GET',
    query: query,
  });
}

export const getrdDemandDeviceObj = (id?: string) => {
  return request<{ data: any }>({
    url: '/pm/rdDemandDevice/' + id,
    method: 'GET',
  });
};

export const getByIdSqlDevice = (data?: Object) => {
  return request<{ data: any }>({
    url: `/pm/rdDemand/getByIdSqlDevice`,
    // url: `/pm/rdDemand/getByIdSql`,
    method: 'POST',
    data: data,
  });
};

// export const getByIdSqlDevice = (query?: Object) => {
//   return request<{ data: any }>({
//     url: `/pm/rdDemand/getByIdSqlDevice`,
//     // url: `/pm/rdDemand/getByIdSql`,
//     method: 'GET',
//     query: query,
//   });
// };

export function getRdDemandPageNoTask(query?: Object) {
  return request({
    url: '/pm/rdDemand/getRdDemandPageNoTask',
    method: 'GET',
    query: query,
  });
}

export function baseTrade(query?: Object) {
  return request({
    // url: '/pm/baseTrade/page',
    url: '/pm/baseTrade/tradeNavigation',
    method: 'GET',
    query: query,
  });
}

export function getRdProjectUser(query?: Object) {
  return request({
    url: '/pm/rdProjectUser/page',
    method: 'GET',
    query: query,
  });
}

export function updateProjectUsers(obj?: Object) {
  return request({
    url: '/pm/rdProjectUser/updateProjectUsers',
    method: 'PUT',
    data: obj,
  });
}
export const getDeptByCodeAndTenantId = (query?: Object) => {
  return request<{ data: any }>({
    url: '/admin/dept/getDeptByCodeAndTenantId',
    method: 'GET',
    query: query,
  });
};

// 分析手段指标
export const baseAnalysisIndex = (query?: Object) => {
  return request<{ data: any }>({
    url: '/pm/baseAnalysisIndex/page',
    method: 'GET',
    query: query,
  });
};
export const fetchPersonApplyList = (query?: Object) => {
  return request<{ data: any }>({
    url: '/pm/rdTaskUserChange/page',
    method: 'GET',
    query: query,
  });
};
export function completePersonApply(obj?: Object) {
  return request({
    url: '/pm/rdTaskUserChange/complete ',
    method: 'POST',
    data: obj,
  });
}

export function updateProjectApplyUsers(obj?: Object) {
  return request({
    url: '/pm/rdTaskUserChange/update',
    method: 'PUT',
    data: obj,
  });
}
export function addProjectApplyUsers(obj?: Object) {
  return request({
    url: '/pm/rdTaskUserChange/save',
    method: 'POST',
    data: obj,
  });
}
export function submitProcessPersonApply(obj?: Object) {
  return request({
    url: '/pm/rdTaskUserChange/submitProcess',
    method: 'POST',
    data: obj,
  });
}

export function revokeProcessPersonApply(query?: Object) {
  return request({
    // url: '/pm/rdDemand/revokeDE',
    url: '/pm/rdTaskUserChange/revoke',
    method: 'POST',
    data: query,
  });
}

export function updateByIdOpinion(obj?: Object) {
  return request({
    url: '/pm/rdDemand/updateByIdOpinion',
    method: 'PUT',
    data: obj,
  });
}

export const saveOpinion = (data?: Object) => {
  return request<{ data: any }>({
    url: `/pm/rdDemand/saveOpinion`,
    method: 'POST',
    data: data,
  });
};

export function updateOpinion(obj?: Object) {
  return request({
    url: '/pm/rdDemand/updateOpinion',
    method: 'PUT',
    data: obj,
  });
}

export const getOpinion = (data?: Object) => {
  return request<{ data: any }>({
    url: '/pm/rdReviewOpinion/getOpinion',
    method: 'POST',
    data: data,
  });
};
